﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bankeren.Engine.Cards;
using System.Threading;

namespace Bankeren.Engine
{
    public class Bot : Player
    {
        #region Fields

        private static Random random = new Random();

        private Difficulty diff;

        #endregion

        #region Ctor

        public Bot(Difficulty diff, Game game, PlayerInfo info, int seat) : base(game, info, seat)
        {
            this.diff = diff;
        }

        #endregion

        #region Methods

        #region Callback Methods

        public override void Welcome(int seat, Dictionary<int, PlayerInfo> players)
        {
            // Ignored.
        }

        public override void PlayerJoined(int seat, PlayerInfo info)
        {
            // Ignored.
        }

        public override void PlayerInfoChanged(int seat, PlayerInfo info)
        {
            // Ignored.
        }

        public override void PlayerLeft(int seat)
        {
            // Ignored.
        }

        public override void GameStarted()
        {
            // Ignored.
        }

        public override void RoundStarted(int roundNumber, int numCards, int dealerSeat, Card trump)
        {
            Random rnd = random;
            game.MakeBid(mySeat, rnd.Next(numCards + 1));
            game.Chat(mySeat, "I bid 1!");
        }

        public override void Bids(Dictionary<int, int> bids)
        {
            // Ignored.
        }

        public override void TrickStarted(int trickNumber)
        {
            // Ignored.
        }

        public override void Turn(int seat, Suit followSuit)
        {
            if (seat == mySeat)
            {
                //Random rnd = random;
                //Thread.Sleep(200 + rnd.Next(400));
                Card card = hand[0];
                hand.RemoveAt(0);
                game.PlayCard(this, card);
            }
        }

        public override void CardPlayed(int seat, Card card)
        {
            // Ignored.
        }

        public override void TrickEnded(int winner)
        {
            // Ignored.
        }

        public override void RoundEnded(Dictionary<int, int> points)
        {
            // Ignored.
        }

        public override void GameEnded(int winner)
        {
            // Ignored.
        }

        public override void Chat(int seat, string message)
        {
            // Ignored.
        }

        public override void ServerStopped(string message)
        {
            // Ignored.
        }

        #endregion

        #endregion

        public enum Difficulty
        {
            Easy,
            Medium,
            Hard
        }
    }
}
